Repository navigation
feat(aws_lambda): add aws_request_id and log_stream_name to the request context - #1624
Conversation
|
Thanks for the contribution! Before we can merge this, we need @kushaldave002 to sign the Salesforce Inc. Contributor License Agreement. |
|
@kushaldave002 Could you sign the Salesforce CLA? We need it signed before we can continue with this PR. 🙏 |
mwbrooks
left a comment
There was a problem hiding this comment.
✅ Thanks @kushaldave002 for this and for the test! 🎉 Congrats on your first contribution to bolt-python!
| bolt_req.context["aws_request_id"] = context.aws_request_id | ||
| bolt_req.context["log_stream_name"] = context.log_stream_name |
There was a problem hiding this comment.
suggestion (non-blocking): The two keys above use an aws_lambda_ prefix, so could we match it here? It keeps them grouped for anyone reading context.
| bolt_req.context["aws_request_id"] = context.aws_request_id | |
| bolt_req.context["log_stream_name"] = context.log_stream_name | |
| bolt_req.context["aws_lambda_request_id"] = context.aws_request_id | |
| bolt_req.context["aws_lambda_log_stream_name"] = context.log_stream_name |
There was a problem hiding this comment.
Renamed in commit 202ddf0, so this is ready to go! 🙏
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1624 +/- ##
=======================================
Coverage 91.57% 91.57%
=======================================
Files 228 228
Lines 7285 7287 +2
=======================================
+ Hits 6671 6673 +2
Misses 614 614 ☔ View full report in Codecov by Harness. |
mwbrooks
left a comment
There was a problem hiding this comment.
✅ Thanks @kushaldave002! This will make it much easier to match Bolt logs to a Lambda invocation. 🚀
Summary
Adds
aws_request_idandlog_stream_namefrom the AWS Lambda context object toBoltRequest.contextinSlackRequestHandler, next to the existingaws_lambda_function_nameandaws_lambda_invoked_function_arn. This makes them available to listeners and middleware for correlating logs with the Lambda invocation.Fixes #1035
Testing
test_lambda_context_in_bolt_contextintests/adapter_tests/aws/test_aws_lambda.pysends a signed event through the handler and checks both values reach the Bolt context. It fails without the handler change../scripts/format.sh --no-install,./scripts/lint.sh --no-install,./scripts/run_mypy.sh --no-install(all pass) andpytest tests/adapter_tests/aws(22 passed).Category
slack_bolt.Appand/or its core componentsslack_bolt.async_app.AsyncAppand/or its core componentsslack_bolt.adapter/docsRequirements
./scripts/install_all_and_run_tests.shafter making the changes.